import request from "@/apps/admin/units/request"
import {HttpResultData, HttpResultPaging} from "@/types/project";

// 用户接口start

/**
 * 广告操作相关权限
 */
export const POWER: any = {
    LIST: 'user.lists'
}


/**
 * 获取用户信息
 * @returns {*}
 */
export function getUserListApi(where: any): Promise<HttpResultPaging<any[]>> {
    return request(`/user/lists`, where)
}


/**
 * 更改会员状态
 * @param id
 * @param status
 */
export function editUserStatus(id: number, status: any) {
    return request(`/user/status`, {id, status}, 'POST')
}


/**
 * 获取会员信息
 * @param id
 */
export function getUserDetail(id: number) {
    return request(`/user/detail`, {id})
}


/**
 * 新建用户api
 */
export const createdUserApi: string = '/user/created'


/**
 * 编辑用户api
 */
export const updatedUserApi: string = '/user/updated'


/**
 * 编辑用户字段API
 */
export const updatedUserFieldApi: string = '/user/updated-field'


/**
 * 删除会员信息
 * @param id
 */
export function deletedUserDetailApi(id: number) {
    return request(`/user/deleted`, {id}, 'POST')
}


/**
 * 恢复会员信息
 * @param id
 */
export function recycleUserApi(id: number) {
    return request(`/user/recycle`, {id}, 'POST')
}


// 用户概览start
/**
 * 会员概览信息
 * @param where
 */
export function getUserOverviewApi<T>(where: { [key: string]: any }): Promise<HttpResultData<T>> {
    return request(`/user/overview`, where)
}

/**
 * 会员注册统计信息
 * @param where
 */
export function getRegisterChartApi<T>(where: { [key: string]: any }): Promise<HttpResultData<T>> {
    return request(`/user/register-chart`, where)
}


/**
 * 会员等级概览
 * @param where
 */
export function getLevelChartApi<T>(where: { [key: string]: any }): Promise<HttpResultData<T>> {
    return request(`/user/level-chart`, where)
}


/**
 * 会员标签概览
 * @param where
 */
export function getTagChartApi<T>(where: { [key: string]: any }): Promise<HttpResultData<T>> {
    return request(`/user/tags-chart`, where)
}
